home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 05.zip
/
BS1 part 5
/
PDraw3.0.adf
/
pdraw_rex.lzh
/
ConvertToBW.pdrx
< prev
next >
Wrap
Text File
|
1992-06-16
|
2KB
|
82 lines
/*
@N
This Genie will convert the current selection of objects to Black and White
*/
msg = PDSetup.rexx(2,0)
units = getclip(pds_units)
if msg ~= 1 then exit_msg(msg)
black = "Black"
white = "White"
obj = pdm_SelFirstObj()
if obj = 0 then exit_msg("Please select a group of objects first")
threshold = pdm_GetForm("Enter black threshold..", 8, "Threshold %:50")
if threshold = '' then exit_msg()
if ~datatype(threshold, n) then exit_msg("Invalid Entry")
if threshold > 100 | theshold < 0 then exit_msg("Invalid Entry")
threshold = 15 * threshold / 100
do while obj ~= 0
lcdata = pdm_GetColorData(pdm_GetLineColor(obj))
red = range(1, 15, word(lcdata, 1) * .3) * 1
green = range(1, 15, word(lcdata, 2) * .59) * 1
blue = range(1, 15, word(lcdata, 3) * .11) * 1
grey = red + green + blue
if grey >= threshold then lcdata = white
else lcdata = black
call pdm_SetLineColor(obj, lcdata)
fill = pdm_GetFillPattern(obj)
parse var fill type '0a'x color1 '0a'x color2 '0a'x a '0a'x b '0a'x c '0a'x d
if type ~= 0 then
do
color1 = pdm_GetColorData(color1)
red = range(1, 15, word(color1, 1) * .3) * 1
green = range(1, 15, word(color1, 2) * .59) * 1
blue = range(1, 15, word(color1, 3) * .11) * 1
grey = red + green + blue
if grey >= threshold then color1 = white
else color1 = black
if type > 1 then
do
color2 = pdm_GetColorData(color2)
red = range(1, 15, word(color2, 1) * .3) * 1
green = range(1, 15, word(color2, 2) * .59) * 1
blue = range(1, 15, word(color2, 3) * .11) * 1
grey2 = red + green + blue
if grey2 >= threshold then color2 = white
else color2 = black
a = 2 /* make grad fills into 2 steps */
if color1 = color2 then type = 1 /* make it a solid fill */
end
call pdm_SetFillPattern(obj, type, color1, color2, a, b, c, d)
end
obj = pdm_SelNextObj(obj)
end
exit_msg()
exit_msg: procedure expose units
do
parse arg message
if message ~= '' then call pdm_Inform(1,message,)
call pdm_SetUnits(units)
call pdm_AutoUpdate(1)
exit
end